package com.ocean.web.controller.product;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ocean.common.annotation.Log;
import com.ocean.common.enums.BusinessType;
import com.ocean.system.domain.OZnwgSq;
import com.ocean.system.service.IOZnwgSqService;
import com.ocean.common.core.controller.BaseController;
import com.ocean.common.core.domain.AjaxResult;
import com.ocean.common.utils.poi.ExcelUtil;
import com.ocean.common.core.page.TableDataInfo;

/**
 * 智能网格省区配置Controller
 * 
 * @author ocean
 * @date 2025-03-28
 */
@Controller
@RequestMapping("/system/sq")
public class OZnwgSqController extends BaseController
{
    private String prefix = "system/sq";

    @Autowired
    private IOZnwgSqService oZnwgSqService;

    @RequiresPermissions("system:sq:view")
    @GetMapping()
    public String sq()
    {
        return prefix + "/sq";
    }

    /**
     * 查询智能网格省区配置列表
     */
    @RequiresPermissions("system:sq:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(OZnwgSq oZnwgSq)
    {
        startPage();
        List<OZnwgSq> list = oZnwgSqService.selectOZnwgSqList(oZnwgSq);
        return getDataTable(list);
    }

    @PostMapping("/xlk")
    @ResponseBody
    public AjaxResult xlk()
    {
        OZnwgSq oZnwgSq = new OZnwgSq();
        List<OZnwgSq> list = oZnwgSqService.selectOZnwgSqList(oZnwgSq);
        return AjaxResult.success(list);
    }

    /**
     * 导出智能网格省区配置列表
     */
    @RequiresPermissions("system:sq:export")
    @Log(title = "智能网格省区配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(OZnwgSq oZnwgSq)
    {
        List<OZnwgSq> list = oZnwgSqService.selectOZnwgSqList(oZnwgSq);
        ExcelUtil<OZnwgSq> util = new ExcelUtil<OZnwgSq>(OZnwgSq.class);
        return util.exportExcel(list, "智能网格省区配置数据");
    }

    /**
     * 新增智能网格省区配置
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存智能网格省区配置
     */
    @RequiresPermissions("system:sq:add")
    @Log(title = "智能网格省区配置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(OZnwgSq oZnwgSq)
    {
        return toAjax(oZnwgSqService.insertOZnwgSq(oZnwgSq));
    }

    /**
     * 修改智能网格省区配置
     */
    @RequiresPermissions("system:sq:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        OZnwgSq oZnwgSq = oZnwgSqService.selectOZnwgSqById(id);
        mmap.put("oZnwgSq", oZnwgSq);
        return prefix + "/edit";
    }

    /**
     * 修改保存智能网格省区配置
     */
    @RequiresPermissions("system:sq:edit")
    @Log(title = "智能网格省区配置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(OZnwgSq oZnwgSq)
    {
        return toAjax(oZnwgSqService.updateOZnwgSq(oZnwgSq));
    }

    /**
     * 删除智能网格省区配置
     */
    @RequiresPermissions("system:sq:remove")
    @Log(title = "智能网格省区配置", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(oZnwgSqService.deleteOZnwgSqByIds(ids));
    }
}
